Skip to content

fix: allow caret placement inside commented text on click (SD-2442)#2708

Merged
caio-pizzol merged 5 commits intomainfrom
luccas/sd-2442-bug-cursor-cannot-be-placed-in-text-associated-with-a
Apr 9, 2026
Merged

fix: allow caret placement inside commented text on click (SD-2442)#2708
caio-pizzol merged 5 commits intomainfrom
luccas/sd-2442-bug-cursor-cannot-be-placed-in-text-associated-with-a

Conversation

@luccas-harbour
Copy link
Copy Markdown
Contributor

Summary

  • Fixes a bug where clicking on text covered by a single comment highlight would short-circuit caret placement, making it impossible to position the cursor within commented text
  • Direct clicks on comment highlight spans now fall through to the generic pointer handling, allowing normal caret placement while still supporting nearby/gap clicks for comment activation
  • Adds a Playwright behavior test (sd-2442-commented-text-caret.spec.ts) and updates existing unit tests to reflect the new behavior

@linear
Copy link
Copy Markdown

linear bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luccas-harbour fix looks good, no bugs found. clicking on commented text places the caret correctly and the right comment gets selected — tested all the cases (single comment, overlapping comments, re-clicking same comment).

one side effect: clicking commented text highlights the comment bubble but doesn't open the reply thread like google docs does. filed SD-2460 for that — not a blocker here.

left one small inline comment on the test helpers.

Comment thread tests/behavior/helpers/editor-interactions.ts
@caio-pizzol caio-pizzol self-assigned this Apr 9, 2026
Pointer capture (used by PresentationEditor during pointerdown) redirects
the click event target to the viewport host. The v-click-outside directive
fires on the click event, so e.target no longer matches the original
comment highlight span. This caused handleClickOutside to clear the active
comment immediately after selection-based activation set it.

Use document.elementFromPoint as a fallback to check what's actually under
the cursor coordinates, so the ignored-selectors check works regardless of
pointer capture.
Unit tests:
- elementFromPoint fallback when e.target is wrong (pointer capture)
- elementFromPoint fallback for tracked-change selectors
- inverse: elementFromPoint returns non-ignored element, bubble dismissed

Behavior tests:
- clicking inside commented text activates the comment bubble
- double-clicking inside commented text selects a word
@caio-pizzol caio-pizzol added this pull request to the merge queue Apr 9, 2026
Merged via the queue into main with commit 8955a80 Apr 9, 2026
54 checks passed
@caio-pizzol caio-pizzol deleted the luccas/sd-2442-bug-cursor-cannot-be-placed-in-text-associated-with-a branch April 9, 2026 01:30
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 9, 2026

🎉 This PR is included in vscode-ext v1.1.0-next.75

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 9, 2026

🎉 This PR is included in @superdoc-dev/react v1.0.0-next.29

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 9, 2026

🎉 This PR is included in esign v2.2.0-next.33

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 9, 2026

🎉 This PR is included in template-builder v1.3.0-next.35

The release is available on GitHub release

Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luccas-harbour fix works well — clicking inside commented text places the cursor correctly now.

found one extra issue while testing: after clicking commented text, the comment bubble would flash active then immediately deselect. the click-outside handler on the comment dialog wasn't recognizing the click landed on a comment highlight (because of how the editor captures mouse events). fixed in 8bf0625.

also cleaned up the test helper math from round 1 (d5ae180) and added tests for everything — cursor placement, bubble staying active, and word selection via double-click.

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 9, 2026

🎉 This PR is included in superdoc v1.24.0-next.72

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 9, 2026

🎉 This PR is included in superdoc-cli v0.5.0-next.73

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 9, 2026

🎉 This PR is included in superdoc-sdk v1.3.0-next.74

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in superdoc-sdk v1.4.0

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in superdoc v1.25.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in superdoc-cli v0.6.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in vscode-ext v2.3.0-next.1

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in template-builder v1.5.0-next.1

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Apr 10, 2026

🎉 This PR is included in esign v2.3.0-next.1

The release is available on GitHub release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants